package demo;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import demo.glut.UserServiceImpl;
import demo.service.Hello;
import demo.service.HelloImpl;
import demo.service.WorldImpl;

public class TestMain {
    public static void test1()
    {
        ApplicationContext ctx=new ClassPathXmlApplicationContext("bean_lec06.xml");
        UserServiceImpl userservice = ctx.getBean("user1", UserServiceImpl.class);
        userservice.login("zhangsan");
    }
    
    public static void test2()
    {
        ApplicationContext ctx=new ClassPathXmlApplicationContext("bean_lec06.xml");
        HelloImpl hello = ctx.getBean("hello", HelloImpl.class);
        hello.foo();
        System.out.println("addUser的返回值为"+hello.addUser("zhangsan", "123456"));
        WorldImpl world = ctx.getBean("world", WorldImpl.class);
        world.bar();
    }
    public static void test3()
    {
        ApplicationContext ctx=new ClassPathXmlApplicationContext("bean_lec06.xml");
        Hello hello = ctx.getBean("hello", Hello.class);
        hello.foo();
        System.out.println("addUser的返回值为"+hello.addUser("zhangsan", "123456"));
        //World world = ctx.getBean("world", World.class);
        //world.bar();
    }
    public static void main(String[] args) {
        test1();
        test2();
        test3();
    }
}
